<%@page import="com.jfinal.kit.PropKit"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<html>
<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<!-- 新 Bootstrap 核心 CSS 文件 -->
		<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

		<!-- 可选的Bootstrap主题文件（一般不用引入） -->
		<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

		<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
		<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

		<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
		<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="http://tb1.bdstatic.com/??/tb/static-common/style/tb.js/dialog_29a9417.css,/tb/static-common/lib/tbui/style/all_1888f28.css" />
		<link rel="stylesheet" href="http://tb1.bdstatic.com/??/tb/_/index_7712603.css,/tb/_/search_2e2269a.css" />
		<link href="../wx/css/ddSecond.css" type="text/css" rel="stylesheet"/>
		<title>注册</title>
		<style>
		.linear-submit1{ 
				margin-top:30px;
				width:74%;
				background: none; 
				font-size: small;
				height:32px; 
				border: 1px solid #dee0e1;
				background: #666;
				border-radius: 10px;
				color: #fff;
				
				} 
				
		</style>
		<script>
		function checkTel(){
			var tel=$("#telNum").val();
			if(tel==''){
				alert("请填写手机号！");
				return false;
			}else{
				var regu = /^0?1[3|4|5|8][0-9]\d{8}$/; 
				var re = new RegExp(regu);
				if(!(re.test(tel))){
					alert("请输入正确的手机号！");
					return false;
				}else{
					return true;
				}
			}

		}
			var i=60;
			function show() {
				if(checkTel()==false){
					return false;
				}else{
					var s=setInterval(time,1000);
					function time(){
						if(i==0){
							$(".linear").show();
							$("#jishi").hide();
							clearInterval(s);
							i=60;
						}else{
							$(".linear").hide();
							$("#jishi").show();
							$("#jishi").val(i+" 秒");
							i--;
						}
						
					}
			var inputcode = document.getElementById("inputcode").value;
			var telNum =document.getElementById("telNum").value;
			
				 $.ajax({
					type : "POST",
					url : "person/getRequest2",
					dataType : "json",
					data : {
						telNum:telNum
					},
					success : function(data) {
					},
					error : function(data) {
					}
				}); 
				}
}
			function show2() {
				if(checkTel()){
					
					var inputcode = $("#inputcode").val();
					
					if(inputcode==''){
						alert('验证码不能为空！');
						return false;
					}
					var inputcode = $("#inputcode").val();
					var telNum = $("#telNum").val();
				$.ajax({
					type : "POST",
					url : "person/getCode",
					dataType : "json",
					data : {
						inputcode:inputcode,
						telNum:telNum
					},
					success : function(data) {
						if(data!=null){
							var code = data["code"];
							
							if(code=="0"){
								alert("感谢您的配合!易行丁丁竭诚为您服务");
								
								 location.href='/person/getUserInfo'; 
								//替换掉前边的页面，返回可退到主界面
							
							}else if(code="1"){
								alert("感谢您的配合!易行丁丁竭诚为您服务");
								
							}else if(code="-1"){
								alert("验证码错误！");
							}
						}
					},
					error : function(data) {
						alert("录制信息失败！");
					}
				});
			}
			}
			
			function codeUp(){
				if(checkTel() && $("#inputcode").val().length>0){
					$(".linear-submit").show();
					$(".linear-submit1").hide();
					}else{
						$(".linear-submit1").show();
						$(".linear-submit").hide();
						return false;
					}
			}
		</script>
	</head>

	<body >
		<div style="">
			<div style="top:25px;width:100%;text-align:center;color: #fff;">
		 		<img class="img1" src="../wx/images/tintin.png" style="width:150px"/>
		 		<p style="margin-top:15px">欢迎加入易行丁丁大家庭</p>
		 		<div class="center">
		 		<input class="center-input" id="telNum" type="tel" placeholder="输入手机号"/><br>
		 		<input class="center-input" id="inputcode" style="width: 45%;" onkeyup="codeUp()" type="tel" placeholder="输入验证码">
		 		<input type="button" class="linear" style="height: 35px;" value="获取验证码" onclick="show()" id="getCode">
		 		<input type="button" class="linear" style="height: 35px;" id="jishi" value="" hidden>
		 		<br>
		 		<input type="button" style="display: none;" class="linear-submit" value="提交" onclick="show2()">	
		 		<input type="button" class="linear-submit1" value="提交" style="height: 35px;" onclick="show2()">	
		 		</div>
			</div>
		</div>
	</body>
</html>